<template>
	<view class="user_INFO">

    <u--form
        labelPosition="left"
        :model="form"
        :rules="rules"
        labelWidth="80"
    >
      <u-form-item
          prop="companyId"
          label="企业码："
      >
		<u--input placeholder="请输入企业码" v-model="form.companyId" border="bottom" clearable class='user_input'></u--input>
      </u-form-item>
      <u-form-item
          prop="username"
          label="姓名："
      >
		<u--input placeholder="请输入您的姓名" v-model="form.username" border="bottom" clearable class='user_input'></u--input>
      </u-form-item>
      <u-form-item
          prop="phone"
          label="手机号："
      >

		<u--input placeholder="请输入手机号" v-model="form.phone" border="bottom" clearable class='user_input'></u--input>
      </u-form-item>

    </u--form>
		<view class="next" @click="nextTo">
			下 一 步
		</view>
		<u-notify ref="uNotify" message="请检查表单内容"></u-notify>
	</view>
</template>

<script>
	export default {
		data() {
			return {
        form:{
          companyId: '',
          username: '',
          phone: '',
          show: false
        },
        rules: {
          'companyId':{
            type: 'integer',
            required: true,
            message: '请填写企业码',
            trigger: ['blur']
          },
          'username':{
            type: 'string',
            required: true,
            min:2,
            max:10,
            message: '请正确输入你的姓名',
            trigger: ['blur']
          },
          'phone':{
            type: 'integer',
            required: true,
            len:11,
            message: '请输入11位手机号',
            trigger: ['blur']
          },

        }
			}
		},
		methods: {

			nextTo() {

				if (!!this.form.companyId && !!this.form.username && !!this.form.phone) {
					uni.navigateTo({
						url: `../SetPassword/SetPassword?companyId=${this.form.companyId}&username=${this.form.username}&phone=${this.form.phone}`
					})
				} else {
					this.$refs.uNotify.show({
						top: 10,
						type: 'warning',
						message: '请检查表单内容',
						duration: 1000 * 2,
						fontSize: 20,
						safeAreaInsetTop: true
					})
				}
			}
		},
		onShow() {
      if(uni.getStorageSync('token')){
        uni.reLaunch({
          url:'/pages/home/home'
        })
      }
			uni.setNavigationBarTitle({
				title: '注 册',
			});

			uni.setNavigationBarColor({
				backgroundColor: '#FFFFFF',
				frontColor: '#333'
			})
		}
	}
</script>

<style lang="scss" scoped>
	.user_INFO {
		padding
    : 50rpx 45rpx;

		.user_input {
			margin: 30rpx 0;
			border-bottom: 1px solid #f6f6f6;
		}

		.next {
			width: 80%;
			text-align: center;
			height: 100rpx;
			line-height: 100rpx;
			margin: 60rpx auto;
			background-color: #1989fa;
			color: #f6f6f6;
			border-radius: 8px;
		}
	}
</style>
